package javabase.schoolwork.day5_24;

/**
 * @author fance
 * @date 2018/5/24 19:45
 */
public class Person {
    private String name;
    private int age;
    private int sex;

    public Person(String name, int age, int sex) {
        this.name = name;
        this.age = age;
        this.sex = sex;
    }

    public Person() {
    }

    public void study() {
        System.out.println("studying");
    }
    public void showAge() {
        System.out.println(age);
    }
    public int addAge(int i) {
        age += i;
        return age;
    }


    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", sex=" + sex +
                '}';
    }

    public static void main(String[] args) {
        Person person1 = new Person("one",10,0);
        Person person2 = new Person("two",3,1);
        System.out.println(person1);
        person1.study();
        person1.showAge();
        System.out.println(person1.addAge(8));


        System.out.println(person2);

        person2.study();
        person2.showAge();
        System.out.println(person2.addAge(3));
    }
}
